home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
DJSRC106.ARJ
/
UTOD.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-30
|
2KB
|
83 lines
/* This program is designed to be compiled under Turbo C */
#include <stdio.h>
#include <dir.h>
#include <dos.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <alloc.h>
#include <string.h>
#include <io.h>
typedef struct F {
char *name;
struct F *next;
} F;
main(argc, argv)
int argc;
char *argv[];
{
F *root=NULL, *n;
int done;
struct ffblk ff;
char path[80], drive[10];
for (argc--, argv++; argc; argc--, argv++)
{
fnsplit(*argv, drive, path, NULL, NULL);
done = findfirst(*argv, &ff, 0);
while (!done)
{
n = (F *)malloc(sizeof(F));
n->name = (char *)malloc(strlen(ff.ff_name)+strlen(drive)+strlen(path)+5);
fnmerge(n->name, drive, path, ff.ff_name, "");
n->next = root;
root = n;
done = findnext(&ff);
}
while (root)
{
utod(root->name);
n = root->next;
free(root->name);
free(root);
root = n;
}
}
}
utod(fname)
char *fname;
{
int sf, df, l, bp1, bp2, saw_13=0;
struct ftime ftime;
char buf[512], buf2[1024]; /* worst case */
char tfname[80], drive[3], path[80];
sf = open(fname, O_RDONLY|O_BINARY);
fnsplit(fname, drive, path, NULL, NULL);
fnmerge(tfname, drive, path, "utod", "c");
df = open(tfname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IWRITE);
while ((l=read(sf, buf, 512)) > 0)
{
bp2 = 0;
for (bp1 = 0; bp1 < l; bp1++)
{
if (!saw_13 && (buf[bp1] == 10))
buf2[bp2++] = 13;
buf2[bp2++] = buf[bp1];
if (buf[bp1] == 13)
saw_13 = 1;
else
saw_13 = 0;
}
write(df, buf2, bp2);
}
getftime(sf, &ftime);
setftime(df, &ftime);
close(sf);
close(df);
remove(fname);
rename(tfname, fname);
}